<template>
	<view class="container">
		<sub-navigationbar text="优惠券获取" btnText="获取记录" url="../take-records/take-records"></sub-navigationbar>
		<view class="content">
			<text class="title">获取方式</text>
			<view class="getways">
				<view class="item" v-for="(i,index) in getWayList" :key="i.name">
					<view class="left-content">
						<text class="h1">{{i.name}}</text>
						<text class="h2">说明：{{i.state}}</text>
						<view class="btn" @click="goDetail(i.id)">前往{{i.name}}</view>
					</view>
					<image class="img-icon" :src="i.icon"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import subNavigationbar from '@/components/sub-navigationbar.vue';
	export default {
		components: {
			subNavigationbar
		},
		data() {
			return {
				getWayList:[
					{id:0,name:'购买',state:"可在进入到优惠券购买页面购买",icon:"../../static/getway_buy.png"},
					{id:1,name:'兑换',state:"在商城购物后可用订单号兑换优惠券",icon:"../../static/getway_exchange.png"},
					{id:2,name:'领取',state:"用户可进入公众号文章页领取优惠券",icon:"../../static/getway_receive.png"},
				]
			};
		},
		methods:{
			goDetail(id) {
				// 购买
				let page = 'coupon-mall';
				// 兑换
				if(id==1) page = 'coupon_exchange';
				// 领取
				if(id==2) {
					uni.showToast({
						title:'暂未开放',
						icon:'none'
					})
					return;
					page = 'coupon-receive'
				};
				uni.navigateTo({
					url:`/pages/${page}/${page}`
				})
			}
		}
	}
</script>

<style lang="scss">
.content {
	padding: 50rpx 34rpx 50rpx 36rpx;
	.title {
		color: #222;
		font-size: 36rpx;
		line-height: 50rpx;
	}
	.getways {
		margin-top: 20rpx;
		display: flex;
		flex-direction: column;
		.item {
			position: relative;
			height: 240rpx;
			width: 680rpx;
			border-radius: 8rpx;
			background: url(../../static/getwaybg.png) no-repeat center center/100% 100% $xy-color-default;
			padding: 30rpx 42rpx 0 36rpx;
			box-sizing: border-box;
			display: flex;
			justify-content: space-between;
			margin-bottom: 24rpx;
			.left-content {
				display: flex;
				flex-direction: column;
				color: #FFFFFF;
				line-height: 1;
				.h1 {
					font-size: 40rpx;
					margin-bottom: 16rpx;
				}
				.h2 {
					font-size: 20rpx;
					line-height: 28rpx;
				}
				.btn {
					position: absolute;
					left: 36rpx;
					bottom: 38rpx;
					width: 176rpx;
					height: 56rpx;
					border-radius: 8rpx;
					background-color: $xy-color-primary;
					font-size: 28rpx;
					color: #fff;
					display: flex;
					align-items: center;
					justify-content: center;
				}
			}
			.img-icon {
				width: 176rpx;
				height: 176rpx;
				margin-top: 6rpx;
			}
		}
	}
}
</style>
